// 获取当前系统UTC时间(秒数)
export function getCurrentTimeInSeconds() {
    return Math.floor(Date.now() / 1000);
}

export function convertLocalDateToUTCSeconds(datetime) {
    let sendRewardTime = new Date(datetime);
    let utcRewardSendTime = sendRewardTime.getTime() - (sendRewardTime.getTimezoneOffset() * 60000); // UTC时间
    // 将UTC时间转换为秒数
    return Math.floor(utcRewardSendTime / 1000);
}

export function convertUTCToLocalDate(utcSeconds) {
    // 将 UTC 秒数转换为毫秒数
    const milliseconds = utcSeconds * 1000;

    // 创建 Date 对象并传入毫秒数
    const date = new Date(milliseconds);

    // 转换为本地时间
    const localDate = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));

    // 获取本地时间的各个部分
    const year = localDate.getFullYear();
    const month = String(localDate.getMonth() + 1).padStart(2, '0');
    const day = String(localDate.getDate()).padStart(2, '0');
    const hours = String(localDate.getHours()).padStart(2, '0');
    const minutes = String(localDate.getMinutes()).padStart(2, '0');
    const seconds = String(localDate.getSeconds()).padStart(2, '0');

    // 将日期的各个部分拼接成字符串
    return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
}

